package com.bzkj.basicinfo.service.impl.ncc;

import com.bzkj.basicinfo.domain.ncc.NccBasicSkuAttribute;
import com.bzkj.basicinfo.domain.ncc.dto.NccBasicSkuInfoDto;
import com.bzkj.basicinfo.mapper.NccBasicSkuAttributeMapper;
import com.bzkj.basicinfo.service.ncc.NccBasicSkuAttributeService;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.domain.model.LoginUser;
import com.bzkj.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author：swj
 * @Desc
 * @Date：2025/6/26 11:20
 */
@Service
public class NccBasicSkuAttributeServiceImpl implements NccBasicSkuAttributeService {
    @Autowired
    private NccBasicSkuAttributeMapper nccBasicSkuAttributeMapper;


    @Override
    public List<NccBasicSkuAttribute> findNccBasicSkuAttributeData(NccBasicSkuInfoDto dto) {
        return nccBasicSkuAttributeMapper.findNccBasicSkuAttributeData(dto);
    }

    @Override
    public AjaxResult updateState(Integer id, String status) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        int i = nccBasicSkuAttributeMapper.updateDoubleReviewById(id, status, loginUser.getUsername());
        if (i < 0) {
            return AjaxResult.success("修改失败");
        }
        return AjaxResult.success("修改成功");
    }

    @Override
    public AjaxResult updateNccBasicSkuAttribute(NccBasicSkuAttribute nccBasicSkuAttribute) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        String username = loginUser.getUsername();
        nccBasicSkuAttribute.setUpdateBy(username);
        int i = nccBasicSkuAttributeMapper.updateNccBasicSkuAtribute(nccBasicSkuAttribute);
        if (i < 0) {
            return AjaxResult.success("修改失败");
        }
        return AjaxResult.success("修改成功");
    }
}
